/*
 * @Descripttion: GGB
 * @version: 1.0
 * @Author: GGB
 * @Date: 2021-08-19 18:19:42
 * @LastEditors: GGB
 * @LastEditTime: 2021-08-19 22:11:27
 */
import 'package:flutter/material.dart';
import 'package:flutter_data_center/utills/color_utils.dart';
import 'package:pie_chart/pie_chart.dart';

class AlertChart extends StatefulWidget {
  const AlertChart({Key key}) : super(key: key);

  @override
  _AlertChartState createState() => _AlertChartState();
}

class _AlertChartState extends State<AlertChart> {
  Map<String, double> dataMap = {
    "Flutter": 5,
    "React": 3,
    "Xamarin": 2,
    "Ionic": 2,
  };
  List<Color> colorList = [
    gColor("#FF06B9"),
    gColor("#FF0642"),
    gColor("#FF8D06"),
    gColor("#FFD706"),
  ];
  ChartType _chartType = ChartType.ring;
  int key = 0;

  @override
  Widget build(BuildContext context) => PieChart(
        key: ValueKey(key),
        dataMap: dataMap,
        animationDuration: Duration(milliseconds: 800),
        chartRadius: 60,
        colorList: colorList,
        initialAngleInDegree: 0,
        chartType: _chartType,
        centerText: null,
        legendOptions: LegendOptions(
          showLegendsInRow: false,
          legendPosition: LegendPosition.right,
          showLegends: false,
          legendShape: BoxShape.circle,
          legendTextStyle: TextStyle(
            fontWeight: FontWeight.bold,
          ),
        ),
        chartValuesOptions: ChartValuesOptions(
          showChartValueBackground: false,
          showChartValues: false,
          showChartValuesInPercentage: false,
          showChartValuesOutside: false,
        ),
        ringStrokeWidth: 15,
        emptyColor: Colors.grey,
      );
}
